{% extends "admin/base.html" %}
{% block body %}

    <div class="container">
        <div class="row">
            <div class="col-md-8 col-sm-8 col-xs-8"><h2>活动管理</h2></div>
            <div class="col-md-4 col-sm-4 col-xs-4">
                <h2 style="float:right"><a href="/admin/event/new" class="btn btn-sm btn-primary">创建活动</a></h2>
            </div>
        </div>
        <hr>
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }}" role="alert">{{ message }}
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        <script type="application/javascript">
            function del(id) {
                $.post("/admin/event/delete", {id: id}, function (data) {
                    if (data.success) {
                        location.reload();
                    }
                });
            }
        </script>
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>活动序号</th>
                <th>活动名称</th>
                <th>地点</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for e in eventList %}
                <tr id="{{ e.id }}">
                    <td>{{ e.id }}</td>
                    <td>{{ e.name }}</td>
                    <td>{{ e.place }}</td>
                    <td>{{ e.create_date }}</td>
                    <td><a href="/admin/event/{{ e.id }}" class="btn btn-sm btn-primary">查看小组</a>&emsp;<a
                            href="javascript:void(0)" onclick="del({{ e.id }})" class="btn btn-sm btn-danger">删除</a></td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

{% endblock %}